<!DOCTYPE html>
<html>
<head>
 <meta name="viewport" content="width=device-width, initial-scale=1" charset="UTF-8">
 <script src="https://cdn.bootcss.com/js-sha1/0.6.0/sha1.min.js"></script>
 <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js"></script>
 <link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/4.0.0-beta/css/bootstrap.min.css">
 <script src="https://cdn.bootcss.com/popper.js/1.12.5/umd/popper.min.js"></script>
 <script src="https://cdn.bootcss.com/bootstrap/4.0.0-beta/js/bootstrap.min.js"></script>
 <script src="https://cdn.bootcss.com/vue/2.5.17-beta.0/vue.js"></script>
<link href="../../ico.ico" rel="icon" type="image/x-icon" />
<script type="text/javascript">
	$(function  () {

			       //login event    
     $('#huo').on('click',function  () {
    
         if(regz()){
         	
         	console.log('启动手机登陆程式')
            let data={};
     	    data.user=$('#user').val()
     	    data.password=$('#pwd').val()
     	    data.list='1'
            
     	    data=JSON.stringify(data)
     	let ur='/jd_mobile?order=phone_login&data='+data;    
     	    ur=encodeURI(ur)
 
          
          	fetch('/jd_mobile?order=phone_login&data='+data, {
				 method: 'GET',
				})
				.then((res)=>{
				return res.json() 
				})
				.then((res)=>{

				$('#login').on('click',function  () {
    

         	
         	let data2={};
     	    data2.user=$('#user').val()
     	    data2.password=$('#pwd').val()
     	    data2.list='0'
            
     	    data2=JSON.stringify(data2)
     	let ur='/jd_mobile?order=phone_login&data='+data2;    
     	    ur=encodeURI(ur)
     	    console.log("pwd"+$('#pwd').val())
     	  
 					if(res==$('#pwd').val()){
				   	location.href='../'
				   }else{
				   	alert('验证码错误')
				   }
           
         	
         	
         	
         	


      })//login click end！！！！  
					
					
					
				   
				   
				   
				   
				   
				})
         	
         	
         	
         	
         	
         }else{
         	login()
         }

      })//login click end！！！！    
			  
  
	})
	
	
	function regz () {
		var myreg=/^[1][3,4,5,7,8][0-9]{9}$/;  
          if (!myreg.test($('#user').val())) {  
              return false;  
          } else {  
              return true;  
          }  
	
	}
	
	function login () {
		/*console.log('启动常规账号登陆')
		     	let data={};
     	    data.user=$('#user').val()
     	    data.password=sha1($('#pwd').val())
            
     	    data=JSON.stringify(data)
     	let ur='/jd_mobile?order=activ&data='+data;    
     	    ur=encodeURI(ur)
 
            location.href=ur*/
// 	           encodeURI()
// 	           encodeURIComponent()
	}
	
	
	
	
</script>
  
</head>


<body>
<div class="container" style="padding: 20px;">	
<form>
  <div class="form-group">
    <label for="user">手机号/账号:</label>
    <input type="text" class="form-control" id="user" placeholder="请输入手机号/账号">
  </div>
  <div class="form-group">
    <label for="text">手机验证码<span style="color: #666;">（密码）</span>:</label>
    <input type="text" class="form-control" id="pwd" placeholder="输入手机验证码">
  </div>

  <button type="button" class="btn btn-primary"  id="huo">获取验证码</button>
  <button type="button" class="btn btn-primary" id="login">登陆</button>
<!--  <button type="button" class="btn btn-danger" id="reg">立即注册</button>-->
  <script type="text/javascript">
  	$('#reg').click(function  () {
  		location.href='/jd_mobile?order=reg'
  	})
  	
    {
    	let n=60
    	function sub_time () {
    		if(n<=0){

	  			$('#huo').attr('disabled',false)
	  			$('#huo').html('获取验证码')
	  		}else{
	  			$('#huo').html(n+'秒后再次获取')
	  			setTimeout(sub_time,1000)
	  			n--
	  		}
    	}
    	
	  	$('#huo').click(function  () {
	  		n=60
	  		$(this).attr('disabled',true)
             sub_time()
	  	})
  	}
 
  </script>
</form>

</div>
</body>
</html>